// pages/recharge/index.js
const app = getApp()
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		userInfo:{},
		address:"",
		setting:{}
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		let that = this;
		app.connect('index/setting', {}, function (res) {
			that.setData({
				setting: res
			})
		});
		//登录
		app.login(function (userInfo) {
			app.checkMobile(userInfo.data);
			that.setData({
				userInfo: userInfo.data
			})
			//获取mag充值地址
			app.connect('account/getMagAddress',{
				uid:that.data.userInfo.uid,
				openid:that.data.userInfo.openId,
				mobile:that.data.userInfo.mobile
			},function(res){
				console.log(res);
				that.setData({
					address: res.data.rechargeAddress
				});
			});
		})
	},
	/**
	 * 点击复制
	 */
	copy:function(e){
		var wz = e.currentTarget.dataset.wz;
		wx.setClipboardData({
			data: wz,
			success: function (res) {
				
			}
		})
	}
})